/*
	Name: Inverse the Problem
	Author: There,hello
	Date: 30-10-19 10:29
	Description: MST 
*/
#include<bits/stdc++.h>
using namespace std;
#define add(x,y,z) edge[++tail]=(dd){head[x],y,z};head[x]=tail;
#define add2(x,y,z) side[++tot]=(dd){hed[x],y,z};hed[x]=tot;
struct dd{
    int ne,to,w;
}edge[4000110],side[5000];
int a[2020][2020],head[2020],tail,cnt,tot,dis[2020],fr[2020],hed[2020];
bool used[2020];
int n;
void prim(){
    priority_queue<pair<int,int> > q;
    memset(dis,0x3f,sizeof(dis));
    dis[1]=0;
    q.push(make_pair(0,1));
    while(!q.empty()&&cnt<n-1){
        pair<int, int> x=q.top();
        q.pop();
        if(used[x.second])continue;
        used[x.second]=1;
        ++cnt;
        for(int i=head[x.second];i;i=edge[i].ne){
            if(!used[edge[i].to] && edge[i].w<dis[edge[i].to]){
                dis[edge[i].to]=edge[i].w;
                fr[edge[i].to]=x.second;
                q.push(make_pair(-edge[i].w,edge[i].to));
            }
        }
    }
}
void creat_(){
    for(int i=2;i<=n;++i){
        if(dis[i]==0x3f3f3f3f){
            printf("NO");
            exit(0);
        }
        add2(i,fr[i],dis[i]);
        add2(fr[i],i,dis[i]);
    }
}
void dfs(int t,int fa){
    for(int i=hed[t];i;i=side[i].ne){
        if(side[i].to!=fa){
            dis[side[i].to]=dis[t]+side[i].w;
            dfs(side[i].to,t);
        }
    }
}
bool check(int t){
    for(int i=1;i<=n;++i)
        if(dis[i]!=a[t][i])return 0;
    return 1;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            scanf("%d",&a[i][j]);
            if(i==j){
            	if(a[i][j]){
            		printf("NO");
					return 0;
				}
				continue;	
			}
			if(a[i][j]==0){
				printf("NO");
				return 0;
			}
            add(i,j,a[i][j]);
        }
    }
    prim();
    creat_();  
    memset(dis,0,sizeof(dis));
    for(int i=1;i<=n;++i){
        dfs(i,i);
        if(!check(i)){
            printf("NO");
            return 0;
        }
        memset(dis,0,sizeof(dis));
    }
    printf("YES");
    return 0;
}
